package com.book.book.model;

import com.book.book.enums.ResultCodeEnum;
import lombok.Data;

@Data
public class Result<T> {
    private ResultCodeEnum code;   //-1未登录，200正常， -2出错
    private String errMsg;
    private T data;

    public static <T>Result succes(T data){
        Result result=new Result();
        result.setCode(ResultCodeEnum.SUCCES);
        result.setErrMsg("");
        result.setData(data);
        return result;
    }
    public static Result unlogin(){
        Result result=new Result();
        result.setCode(ResultCodeEnum.UNLOGIN);
        result.setErrMsg("未登录");
        result.setData(null);
        return result;
    }

    public static <T>Result fail(String Msg,T data){
        Result result=new Result();
        result.setCode(ResultCodeEnum.FAIL);
        result.setErrMsg(Msg);
        result.setData(data);
        return result;
    }



}
